﻿@{
    Layout = null;
}
@model ElingOA6_Admin_DSJCJ.Model.ItemCls
<!DOCTYPE html>
@Html.Partial("LoadPanelPartial")
<html>
<head>
<title>用品类别</title>
      @if (false)
    {
        <script src="../../../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>
    }
    <link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />

    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/FloatDiv.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>
    
    @Html.DevExpress().GetStyleSheets(

                new StyleSheet { ExtensionType = ExtensionType.GridView, Theme = DevExpressHelper.Theme }

)
    @Html.DevExpress().GetScripts(
                    new Script { ExtensionType = ExtensionType.ListBox }
    )
    <script type="text/javascript">

        $(document).ready(function () {
            var hdjsAlert = $("#hdjsAlert").val();
            if (hdjsAlert != "") {
                alert(hdjsAlert);
            }
        });

        $(function () {
            $("#toolMenu").smartFloat();
        });


        function MenuTop_emClick(source, e) {
            switch (e.item.name) {
                case "btnSave":
                    {
                        //保存
                        if (FItemClsNo.GetText() == "") {
                            alert("用品类别编号不能为空！");
                            return;
                        }
                        if (FItemClsName.GetText() == "") {
                            alert("用品类别名称不能为空！");
                            return;
                        }

                        form1.submit();
                        break;
                    }

                case "btnAdd":
                    {
                        //增加
                        window.location.href = rootPath + "/Admin/OfficeItemCls/OfficeItemClsEdit";
                        break;
                    }
                case "btnDelete":
                    {
                        //删除
                        var itemClsNo = FItemClsNo.GetText();
                        if (itemClsNo == "") {
                            alert("请选择要删除的类别!");
                        } else {
                            OfficeItemClsDel(itemClsNo);
                        }

                        break;

                    }
            }
        }


        function OfficeItemClsDel(itemClsNo) {
            if (confirm("确定删除")) {
                $.ajax({
                    type: 'POST',
                    url: rootPath + '/Admin/OfficeItemCls/Delete',
                    data: { itemClsNo: itemClsNo },
                    success: function (result) {
                        if (result == "ok") {
                            alert("删除成功!");
                            parent.window.location.href = rootPath + "/Admin/OfficeItemCls";
                        } else if (result == "exists") {
                            alert("该类别已有信息存在,无法直接删除!");
                        } else if (result == "error") {
                            alert("删除失败!");
                        }
                    }
                });
            
             }
        
         }



    </script>
</head>
<body>
@using (Html.BeginForm("Save", "OfficeItemCls", FormMethod.Post, new { id = "form1" }))
{
   <div class="floatToolMenu" id="toolMenu">
        @Html.DevExpress().Menu(settings =>
       {
           settings.Name = "toolBarMenu";
           settings.ItemAutoWidth = false;
           settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
           settings.Styles.Style.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
           settings.Styles.Style.BorderTop.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);

           settings.Items.Add(item =>
           {
               item.Name = "btnSave";
               item.Text = "保存";
               item.ItemStyle.ForeColor = System.Drawing.Color.Red;
               item.ClientEnabled = true;
               item.Image.Url = Url.Content("~/Content/ControlImages/filesave.png");

           });

           settings.Items.Add(item =>
           {
               item.Name = "btnAdd";
               item.Text = "增加";
               item.ClientEnabled = true;
               item.Image.Url = Url.Content("~/Content/ControlImages/edit_add.png");

           });
           settings.Items.Add(item =>
           {
               item.Name = "btnDelete";
               item.Text = "删除";
               item.ItemStyle.ForeColor = System.Drawing.Color.Red;
               item.ClientEnabled = true;
               item.Image.Url = Url.Content("~/Content/ControlImages/cancel.png");

           });

           settings.ClientSideEvents.ItemClick = "function(source,e){MenuTop_emClick(source,e)}";
           settings.ItemLinkMode = ItemLinkMode.ContentBounds;
       }).GetHtml()
    </div>
      <table width="100%">
        <tr >
            <td width="15%" height="25" align="right" valign="middle">
            用品类别编号:
            </td>
            <td width="85%" valign="middle">
              @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "FItemClsNo";
                   settings.Width = System.Web.UI.WebControls.Unit.Pixel(500);
                   settings.Text = Model.FItemClsNo;
                   settings.Enabled = (bool)ViewData["Cls"];
                   settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
                   settings.Properties.ValidationSettings.EnableCustomValidation = true;
               }).GetHtml()
            </td>           
        </tr>
        <tr>
         <td width="15%" height="25" align="right" valign="middle">
            用品类别名称:
            </td>
            <td width="85%" valign="middle">
		     @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "FItemClsName";
                   settings.Width = System.Web.UI.WebControls.Unit.Pixel(500);
                   settings.Text = Model.FItemClsName;
                   settings.Enabled = true;
                   settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
                   settings.Properties.ValidationSettings.EnableCustomValidation = true;
               }).GetHtml()
		    </td>
        
        </tr>     
    </table>
    @Html.Hidden("hdjsAlert", (ViewData["jsAlert"]));
    @Html.Hidden("hdtype", ViewData["type"])                                                
}
     <script type="text/javascript">
         lp.Hide();
    </script>
</body>
</html>
